use openmls_traits::{key_store::OpenMlsKeyStore, OpenMlsCryptoProvider};

/// Shim OpenMLS crypto provider impl around a keystore, which is the only
/// component that needs external data.
pub struct SimpleMlsProvder<K> {
    rust_crypto: openmls_rust_crypto::RustCrypto,
    keystore: K,
}

impl<K> SimpleMlsProvder<K> {
    pub fn new(keystore: K) -> Self {
        Self {
            rust_crypto: openmls_rust_crypto::RustCrypto::default(),
            keystore,
        }
    }
}

impl<K: OpenMlsKeyStore> OpenMlsCryptoProvider for SimpleMlsProvder<K> {
    type CryptoProvider = openmls_rust_crypto::RustCrypto;
    type RandProvider = openmls_rust_crypto::RustCrypto;
    type KeyStoreProvider = K;

    fn crypto(&self) -> &Self::CryptoProvider {
        &self.rust_crypto
    }

    fn rand(&self) -> &Self::RandProvider {
        &self.rust_crypto
    }

    fn key_store(&self) -> &Self::KeyStoreProvider {
        &self.keystore
    }
}
